import { Tooltip } from 'ant-design-vue';
import { h } from 'vue';

export const SetTooltip = (text, length?) => {
  // 检查文本长度是否超过最大长度
  if (length && text.length > length) {
    return h(
      Tooltip,
      {
        title: text,
      },
      () =>
        h(
          'div',
          {
            style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' },
          },
          text,
        ),
    );
  } else {
    // 如果文本长度未超过最大长度,直接返回文本
    return h(
      'div',
      {
        style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' },
      },
      text,
    );
  }
};

export const width100 = 100;

export const width120 = 120;

export const width140 = 140;

export const width150 = 160;

export const width170 = 170;

export const width280 = 280;

export const mwidth100 = 100;

export const mwidth80 = 80;

export const mwidth120 = 120;

export const width140px = '140px';

export const width160px = '160px';

export const width180px = '180px';
